/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.univcasa.db.persist;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author issam
 */
public class JDBCTest {

    public static void main(String[] args){

        try{
            Class.forName("com.mysql.jdbc.Driver");
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }
        try {
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/comptes_ent","root" ,"mayapass");
            DatabaseMetaData meta = con.getMetaData();
            System.out.println(  meta.getDriverName() + meta.getDriverVersion() ) ;
            Statement stmt = con.createStatement();
            ResultSet results = stmt.executeQuery("SELECT * FROM comptes_personnel c;");
            //System.out.println( "resultset metadata:" + results.getMetaData().getColumnCount() );
            while (results.next() ){
                for (int i=1; i<results.getMetaData().getColumnCount(); i++ )
                    System.out.println( results.getString( i ) );
                    System.out.println();
            }

        }catch (SQLException ex){
            ex.printStackTrace();
        }

    }

}
